﻿Public Class clsGtProcedureDetails

    Public Function getGtProcedureDetailsList(b_gt_sys_id As String, procedure_no As String) As DataTable
        Dim szSql As String = ""
        szSql &= " select * from sf.b_gt_procedure_details "
        szSql &= "where b_gt_sys_id = ? and validity = ? and procedure_no = ?"
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, b_gt_sys_id, "1", procedure_no)
        If IsNothing(dt) Then
            getGtProcedureDetailsList = New DataTable
        Else
            getGtProcedureDetailsList = dt
        End If
    End Function

    Public Function save(en As entity_gt_procedure_details) As Integer
        Dim sql As String = ""
        Dim rtn As Integer
        DBacs.BeginTransaction()
        Try
            sql &= "INSERT INTO sf.b_gt_procedure_details(procedure_no,oper_num,b_gt_sys_id,validity,operator,update_time) "
            sql &= "VALUES (?,?,?,?,?,(SELECT CURRENT_TIMESTAMP(6)))"
            rtn = DBacs.ExecuteUpdateSql(sql, -1, en.procedure_No, en.oper_num, en.b_gt_sys_id, en.validity, en.oper)

            sql = ""
            sql &= "UPDATE sf.b_gt "
            sql &= " SET status = ?, update_time = (SELECT CURRENT_TIMESTAMP(6))"
            sql &= " WHERE sys_id = ? "
            rtn = DBacs.ExecuteUpdateSql(sql, -1, "1", en.b_gt_sys_id)

            DBacs.CommitTransaction()
        Catch ex As Exception
            DBacs.RollbackTransaction()
            rtn = -2
        End Try
        Return rtn
    End Function

End Class
